# coding=utf-8

import zmq
import time
import random

ctx = zmq.Context.instance()
socket = ctx.socket(zmq.PUB)
socket.bind('tcp://*:5556')
socket.bind("ipc://weather.ipc")

while True:
    zipcode = random.randint(1, 100000)
    temperature = random.randint(-80, 135);
    relhumidity = random.randint(10, 60);

    # json_data = {
    #     'zipcode': zipcode,
    #     'temperature': temperature,
    #     'relhumidity': relhumidity,
    # }

    update = '%05d %d %d' %(zipcode, temperature, relhumidity)
    socket.send(update)

socket.close()
ctx.destroy()
